package com.atguigu.condition;

import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

public class ConditionLinux implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Environment environment = context.getEnvironment();
        BeanDefinitionRegistry registry = context.getRegistry();
        String osName = environment.getProperty("os.name");

        if (osName.contains("linux")) {
            System.out.println("ConditionLinux match true");
//            registry.registerBeanDefinition("osLinux",);
            return true;
        }

        System.out.println("ConditionLinux match false");
        return false;
    }
}
